package com.qianfeng.smartdevice.dto;

import com.qianfeng.smartdevice.pojo.CheckNull;
import org.springframework.util.StringUtils;

/**
 * Created by jackiechan on 2021/6/7 17:26
 * 这个类主要是在添加修改数据的时候传递内容的,
 * 不用 user 的原因是因为 user中的密码等数据是需要展示的,所以忽略了,导致用户即便是传递了密码也不能解析
 *
 * @author jackiechan
 */

public class UserDto implements CheckNull {

    private Long id;
    private String username;
    private String password;
    private String type;
    private String status;

    @Override
    public boolean isNull() {
        if (id == null) {
            return StringUtils.isEmpty(username) || StringUtils.isEmpty(password);
        }else{
            //如果是更新代表必须所有数据都是空的情况下才是空,有任意一个数据不为空则代表可以更新
            return StringUtils.isEmpty(username) && StringUtils.isEmpty(password)&&StringUtils.isEmpty(type)&&StringUtils.isEmpty(status);
        }
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getType() {
        type = StringUtils.isEmpty(type) ? "0" : type;
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getStatus() {
        status = StringUtils.isEmpty(status) ? "1" : status;
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
}